<include file=".:Common:header" />
<style type="text/css">
.device-total { position:absolute; right:10px; top:15px; }
.device-total a { margin-right:10px; }
</style>
<div class="wrapper clear">
  <div class="main">
    <if condition="!empty($button)">
      <div class="toolbar">
        <h3><a href="#" id="querybtn" onclick="tosearch()">查询</a>
       <a onclick="viewDevice()" class="button-query2-center" href="javascript:;">详情</a>
       <a onclick="print_tm()" class="button-query2-center" href="javascript:;">打印条码</a>
        <a href="#" id="editright" onclick="yiimport()">导入</a></h3>
      </div>
    </if>
    <script language="javascript">
/**
*自动完成功能
*/
$(function(){
	autocomplete('OUTERCODE','OUTERCODE');
});
//导入
function yiimport(){
		$.dialog({
			title:'导入数据',
			id:'view_device-set',
			init: dialogURI('/nyi/yi/import_view', ''),
			padding:5,
			width: 800,
			height:100,
			ok: function(){
				$.ajax({
					url:'/nyi/yi/import',
					type:'post',
					dataType:'json',
					data:{file_url: $('#file_url').val()},
					success:function(data){
						if(data.status){
						    $('#datagrid').datagrid('reload');
							alert('导入成功！');
						}else{
							alert(data.info);
						}
					},
					error:function(){
						alert('系统繁忙或网络不通，请重试！');
					}
				});
				return true;
			},
			cancel: true
		});
}
/*成衣厂详情*/
function viewDevice(){
	var row = $('#datagrid').datagrid('getSelected');
	if(row){
		$.dialog({
			title:'厂衣厂详情',
			id:'view_device-set',
			init: dialogURI('/nyi/yi/view_device', {id: row.id}),
			padding:5,
			width: 600,
			height:220,
			fixed: false,
			ok: true
		});
	}
}
/*打印条码*/
function print_tm(){
	var row = $('#datagrid').datagrid('getSelected');
	if(row){
		$.dialog({
			title:'条码打印',
			id:'view_device-set',
			init: dialogURI('/nyi/yi/print_tm', {id: row.id}),
			padding:5,
			width: 300,
			height:150,
			fixed: false,
			ok: true
		});
	}
}

	
$(function(){
		$('#datagrid').datagrid({
		url : '{:U("nyi/yi/yilist")}&d='+Math.random(),
		queryParams:{
			status:1,
			type:1
			},		
		title: '成衣厂',
		width: '100%',
		pagination : true,
		pageSize : <?php if(Cookie('rows')){echo Cookie('rows');}else{echo 10;}?>,
		striped:true,
		singleSelect :true,
		idField: 'id',
		columns: [[
			{title:'IDENTNO', field:'IDENTNO', width:100, sortable: true,align:'right',checkbox:true},
			{title:'IDENTDESC', field:'IDENTDESC', width:100,align:'center'},
			{title:'LABTYP', field:'LABTYP',width:100},
			{title:'LABTYPDESC', field:'LABTYPDESC', width:140, sortable: true},
			{title:'QUANTITY', field:'QUANTITY', width:130},
			{title:'OCPFACTOR', field:'OCPFACTOR', width:140},
			{title:'COUNTRYO', field:'COUNTRYO', width:100},
			{title:'CSDDATE', field:'CSDDATE', width:130},
			{title:'OUTERCODE', field:'OUTERCODE', width:130}
		]],
		onSelect:function(){  
			tohidedit();
				}
	});
});

function edit(){
	var row = $('#datagrid').datagrid('getSelected');
    $("#query").slideUp(100);
	if(row){
	    $("#edit_device").find("#network").val( row.network );
		$("#edit_device").find("#operater").val( row.operater );
		$("#edit_device").find("#state").val(row.state);
		changecity(row.city, "edit_device");
		$("#edit_device").find("#did").val( row.did );
		$("#edit_device").find("#lac").val( row.lac );
		$("#edit_device").find("#cid").val( row.cid );
		$("#edit_device").find("#bid").val( row.bid );
		$("#edit_device").find("#ipaddress").val( row.ipaddress );
		$("#edit_device").find("#mnc").val( row.mnc );
		$('#edit_device').find('#model').val(row.model);
		$('#edit_device').find('#remark').val(row.remark);
		$("#edit_device").slideToggle('fast');	
	}
}
function toupdate(){
    $('#ff').form('submit',{
		url: '{:U('Device/toupdate')}&ajax=true',
	    onSubmit:function(){ 
			return $('#ff').form('validate');
		},
	    success:function(data){
		var data = runJson(data);
				if(data.status == 0){
					alertText(data.info, 'error');
				}else{
					$.messager.alert('系统提示','修改成功!','info');
					$("#edit_device").slideToggle('fast');	
			      	$('#datagrid').datagrid('reload');	
				}
	        }
	   }
    );
}

function query(){
	  $('#datagrid').datagrid('options').queryParams={
	  data:{
		  OUTERCODE: $("#query").find('#OUTERCODE').val(),
	    }
	  }
	 $('#datagrid').datagrid('options').pageNumber=1;
	 $('#datagrid').datagrid('reload');
	 $('#datagrid').datagrid('getPager').pagination({pageNumber:1});
}

/*add*/
function add(){
	toUrl('{:U("Testplan/add")}');
}
/*end add*/
function tosearch(){
	$("#edit_device").slideUp('fast');
	$("#query").slideToggle('fast');
	$("#query").find('#status').val(-1);
	$('#divarrowdown a').toggleClass('on');
	//$("#query").show();
}
/*取消*/
function tohidden(){
$('#ff').form('clear');
$("#query").hide();
}
/*隐藏修改*/
function tohidedit(){
	$("#edit_device").hide();
}
</script>
    <!--query-->
    <script src="__PUBLIC__/js/common/swfobject.js"></script>
    <div class="search">
      <div class="searchbox">
        <div id="query" style="display:none">
          <h3>查询</h3>
          <table class="tableform" cellpadding="0" cellspacing="0" style="width:600px;">
            <tr>
              <th>OUTERCODE</th>
              <td><input title="text" name="OUTERCODE" id="OUTERCODE" size="40"/>
              </td>
            </tr>
          </table>
          <div style="text-align:center; padding: 0px;">
            <input type="button" class="query" value="查询" onclick="query()"/>
            <input type="button" class="cancel" value="取消" onclick="tosearch()"/>
          </div>
        </div>
          </form>
        </div>
      </div>
    </div>
    <!--end-query-->
    <div id="divarrowdown"><a href="#" id="expand" onclick="tosearch()"></a></div>
    <!--end-->
    <div class="table_wrap" style="position:relative;">
      <div class="table_list">
        <table id="datagrid">
        </table>
      </div>
    </div>
  </div>
</div>
<include file=".:Common:footer" />